using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using FikriKibar.Entities.Concrete;

namespace FikriKibar.DataAccess.Mapping
{
    public class SessionHistoryMapping : EntityTypeConfiguration<SessionHistory>
    {
        public SessionHistoryMapping()
            : this("dbo")
        {
        }
 
        public SessionHistoryMapping(string schema)
        {
            ToTable(schema + ".SessionHistory");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.UpdateDate).HasColumnName("UpdateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.LogoutType).HasColumnName("LogoutType").IsRequired().HasColumnType("nvarchar").HasMaxLength(50);

            HasRequired(a => a.User).WithMany(b => b.SessionHistories).HasForeignKey(c => c.CreatedBy);
        }
    }

}
